package com.fadis.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class FadisUtils {

    private static final Random random = new Random(System.currentTimeMillis());

    public static String replaceSpecialChar(String s){

        return s;
    }

    public static int getNormalIndex(int indexMayBeNegative, int len){
        if(indexMayBeNegative >= 0) return indexMayBeNegative;
        // -1 len-1
        // -2 len-2
        return len + indexMayBeNegative;
    }
    public static long getNormalIndex(long indexMayBeNegative, long len){
        if(indexMayBeNegative >= 0) return indexMayBeNegative;
        // -1 len-1
        // -2 len-2
        return len + indexMayBeNegative;
    }

    public static List<String> newArrayList(String...items){
        List<String> list = new ArrayList<>();
        for (int i = 0; i < items.length; i++) {
            list.add(items[i]);
        }
        return list;
    }

    public static int randomInt(int minInclude, int maxInclude){
        int range = maxInclude - minInclude + 1;
        int i = random.nextInt(range); //[0, range - 1]
        return i + minInclude;
    }
}
